//
//  ReleaseCaseView.m
//  yonghu
//
//  Created by 浪尖渝力 on 2018/1/15.
//  Copyright © 2018年 com.DJS. All rights reserved.
//

#import "ReleaseCaseView.h"
#import "selectRegionView.h"
#import "SelectCaseView.h"
#import "CaseProgressViewController.h"
#import "XLSViewController.h"
#import "OKViewController.h"
#import "XQMSView.h"
#import "PingJiaViewController.h"
#import "WEBViewController.h"
@implementation ReleaseCaseView

-(void)creatView{
    self.backgroundColor=_LightGrey;
    _xieYi=YES;
    _scrollView=[UIScrollView new];
    [self addSubview:_scrollView];
    [_scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];
    _scrollView.scrollsToTop =NO;
    
    _scrollView.showsVerticalScrollIndicator = FALSE;
    _scrollView.showsHorizontalScrollIndicator = FALSE;
    _scrollView.bounces = NO;
    if (@available(iOS 11.0, *)) {
        self.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        self.viewController.automaticallyAdjustsScrollViewInsets = NO;
    }
    
    UIScrollView *scrollView2=[UIScrollView new];
    [_scrollView addSubview:scrollView2];
    [scrollView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(NAV_HEIGHT);
        make.left.mas_equalTo(0);
        make.height.mas_equalTo(120);
        make.width.mas_equalTo(_mainW);
    }];
    scrollView2.scrollsToTop =NO;
    scrollView2.showsVerticalScrollIndicator = FALSE;
    scrollView2.showsHorizontalScrollIndicator = FALSE;
    scrollView2.bounces = NO;
    scrollView2.contentSize = CGSizeMake(585,0);
    
    UIView *topView=[UIView new];
    [scrollView2 addSubview:topView];
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.mas_equalTo(0);
        make.width.mas_equalTo(585);
        make.height.mas_equalTo(120);
    }];
    [self creatTopView:topView];
    if (_dic==nil) {
         [self creatView1];
    }
    if (_dic!=nil) {
        NSNumber *document_status=[_dic objectForKey:@"document_status"];
        if (document_status.integerValue==0) {
            [self creatNeiRongView];
        }
//        if (document_status.integerValue==1) {
//            [self pingJiaView];
//
//            UIButton *btn1=[UIButton new];
//            [self addSubview:btn1];
//            [btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
//                make.left.mas_equalTo(0);
//                make.width.mas_equalTo(_mainW);
//                make.height.mas_equalTo(50);
//                make.bottom.mas_equalTo(0);
//            }];
//            [btn1 setTitle:@"立即评价" forState:0];
//            [btn1 setTitleColor:[UIColor whiteColor] forState:0];
//            btn1.backgroundColor=_backgroundColor;
//            [btn1 addTarget:self action:@selector(pijiama:) forControlEvents:UIControlEventTouchUpInside];
//        }
//        if (document_status.integerValue==2) {
//
//            [self wangChengView];
//        }
    }
    
}

-(void)creatTopView:(UIView *)topView{
    UIView *xianView=[UIView new];
    [topView addSubview:xianView];
    [xianView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(25);
        make.right.mas_equalTo(-25);
        make.top.mas_equalTo(35);
        make.height.mas_equalTo(1.5);
    }];
    xianView.backgroundColor=ColorWithRGB(200, 200, 201);
    
    NSArray *arr=[NSArray arrayWithObjects:@"发布委托",@"待回访",@"待签约",@"等待方案",@"律师执行",@"评价",@"完成", nil];
    int index=0;
    if (_dic!=nil) {
        NSNumber *document_status=[_dic objectForKey:@"litigation_status"];
        index=document_status.intValue+1;
    }
    if (index==5) {
        self.viewController.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"评价" style:UIBarButtonItemStylePlain target:self action:@selector(pijiama:)];
    }
    for (int i=0; i<arr.count; i++) {
        UIImageView *imageView=[UIImageView new];
        [topView addSubview:imageView];
        [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(85*i+25);
            make.centerY.mas_equalTo(xianView);
            if (i==index) {
                make.width.height.mas_equalTo(33);
            }
            else{
                make.width.height.mas_equalTo(25);
            }
        }];
        if (i>index) {
            imageView.image=[UIImage imageNamed:@"圆-1"];
        }
        else if (index==i) {
            imageView.image=[UIImage imageNamed:@"圆3"];
        }
        else if (index>i){
            imageView.image=[UIImage imageNamed:@"圆2"];
        }
        
        UILabel *label=[UILabel new];
        [topView addSubview:label];
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(imageView);
            make.bottom.mas_equalTo(-20);
        }];
        label.text=arr[i];
        if (index==i) {
            label.textColor=_backgroundColor;
            label.font=[UIFont systemFontOfSize:18];
        }
        else{
            label.textColor=ColorWithRGB(149, 149, 149);
            label.font=[UIFont systemFontOfSize:15];
        }
    }
}


-(IBAction)pijiama:(id)sender{
    PingJiaViewController *pingJia=[PingJiaViewController new];
    pingJia.evaluate_services_id=[_dic objectForKey:@"litigation_id"];
    pingJia.evaluate_services_type=@3;
    pingJia.evaluate_waiter_id=[_dic objectForKey:@"assign_waiter_id"];
    [ZQTools pushNextViewController:self.viewController andRootController:pingJia];
}

-(void)creatNeiRongView{
    
    UIView *topView=[UIView new];
    [_scrollView addSubview:topView];
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(5);
        make.width.mas_equalTo(_mainW-10);
        make.height.mas_equalTo(280);
        make.top.mas_equalTo(195);
    }];
    topView.backgroundColor=[UIColor whiteColor];
    topView.layer.cornerRadius=3;
    
    UIImageView *iamgeView=[UIImageView new];
    [topView addSubview:iamgeView];
    [iamgeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(10);
        make.width.height.mas_equalTo(60);
    }];
    iamgeView.layer.cornerRadius=30;
    iamgeView.layer.masksToBounds=YES;
    NSString *news_cover=[_dic objectForKey:@"user_icon"];
    news_cover=[NSString stringWithFormat:@"%@%@",_addressUrl,news_cover];
    [iamgeView sd_setImageWithURL:[NSURL URLWithString:news_cover]];
    
    NSString *phoneStr=[_dic objectForKey:@"user_nickname"];
    UILabel *label=[UILabel new];
    [topView addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(iamgeView.mas_right).mas_equalTo(6);
        make.top.mas_equalTo(iamgeView);
        make.right.mas_equalTo(-120);
    }];
    label.text=phoneStr;
    label.textColor=ColorWithRGB(49, 49, 49);
    label.font=[UIFont systemFontOfSize:17];
    
    NSNumber *time=[_dic objectForKey:@"litigation_time"];
    UILabel *timeLabel=[UILabel new];
    [topView addSubview:timeLabel];
    [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(label);
        make.bottom.mas_equalTo(iamgeView);
    }];
    timeLabel.text=[ZQTools changeTimeCuo:@"YYYY-MM-dd HH:mm:ss" :[NSString stringWithFormat:@"%@",time]];
    timeLabel.font=[UIFont systemFontOfSize:14];
    timeLabel.textColor=ColorWithRGB(149, 149, 149);
    
    NSString *consult_ct_name=[_dic objectForKey:@"litigation_ct_name"];
    CGSize size=[ZQTools getNSStringWeight:consult_ct_name andViewWight:20 andFont:18];
    UILabel *ct_nameLabel=[UILabel new];
    [topView addSubview:ct_nameLabel];
    [ct_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(timeLabel);
        make.height.mas_equalTo(30);
        make.top.mas_equalTo(iamgeView.mas_bottom).mas_equalTo(15);
        make.width.mas_equalTo(size.width+14);
    }];
    ct_nameLabel.text=consult_ct_name;
    ct_nameLabel.font=[UIFont systemFontOfSize:16];
    ct_nameLabel.layer.borderWidth=1;
    ct_nameLabel.layer.borderColor=ColorWithRGB(132, 189,226).CGColor;
    ct_nameLabel.textColor=ColorWithRGB(132, 189,226);
    [ct_nameLabel layoutIfNeeded];
    ct_nameLabel.textAlignment=NSTextAlignmentCenter;
    ct_nameLabel.layer.cornerRadius=4;
    
    
    UIView *typeView=[UIView new];
    [topView addSubview:typeView];
    [typeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(ct_nameLabel.mas_bottom).mas_equalTo(10);
    }];
    typeView.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapGesture12 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(XQMS)];
    [typeView addGestureRecognizer:tapGesture12];
    
    UILabel *typeLabel=[UILabel new];
    [typeView addSubview:typeLabel];
    [typeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(0);
    }];
    typeLabel.text=@"案件类型";
    typeLabel.font=[UIFont systemFontOfSize:17];
    typeLabel.textColor=ColorWithRGB(49, 49, 49);
    
    UIImageView *jianTou=[UIImageView new];
    [typeView addSubview:jianTou];
    [jianTou mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(0);
        make.width.mas_equalTo(10);
        make.height.mas_equalTo(15);
    }];
    jianTou.image=[UIImage imageNamed:@"iconfont-fanhui-拷贝-3"];
    
    UILabel *label1=[UILabel new];
    [typeView addSubview:label1];
    [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(jianTou.mas_left).mas_equalTo(-10);
        make.centerY.mas_equalTo(0);
    }];
    label1.text=consult_ct_name;
    label.font=[UIFont systemFontOfSize:17];
    label.textColor=ColorWithRGB(79, 79, 79);
    
    UIView *XianView=[UIView new];
    [topView addSubview:XianView];
    [XianView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(0);
        make.top.mas_equalTo(typeView.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    XianView.backgroundColor=_LightGrey;
    
    
    UIView *typeView2=[UIView new];
    [topView addSubview:typeView2];
    [typeView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(XianView.mas_bottom);
    }];
    
    UILabel *typeLabel2=[UILabel new];
    [typeView2 addSubview:typeLabel2];
    [typeLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(0);
    }];
    typeLabel2.text=@"委托人称呼";
    typeLabel2.font=[UIFont systemFontOfSize:17];
    typeLabel2.textColor=ColorWithRGB(49, 49, 49);
    
    UILabel *label3=[UILabel new];
    [typeView2 addSubview:label3];
    [label3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(0);
    }];
    label3.text=[_dic objectForKey:@"litigation_party_name"];
    label3.font=[UIFont systemFontOfSize:17];
    label3.textColor=ColorWithRGB(79, 79, 79);
    
    UIView *XianView2=[UIView new];
    [topView addSubview:XianView2];
    [XianView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(0);
        make.top.mas_equalTo(typeView2.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    XianView2.backgroundColor=_LightGrey;
    
    
    UIView *typeView3=[UIView new];
    [topView addSubview:typeView3];
    [typeView3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(XianView2.mas_bottom);
    }];
    
    UILabel *typeLabel3=[UILabel new];
    [typeView3 addSubview:typeLabel3];
    [typeLabel3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(0);
    }];
    typeLabel3.text=@"案件所在地";
    typeLabel3.font=[UIFont systemFontOfSize:17];
    typeLabel3.textColor=ColorWithRGB(49, 49, 49);
    
    UILabel *label4=[UILabel new];
    [typeView3 addSubview:label4];
    [label4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(0);
    }];
    label4.text=[_dic objectForKey:@"litigation_city_name"];
    label4.font=[UIFont systemFontOfSize:17];
    label4.textColor=ColorWithRGB(79, 79, 79);
    
    UIImageView *imageView=[UIImageView new];
    [_scrollView addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(topView.mas_bottom).mas_equalTo(50);
        make.height.width.mas_equalTo(90);
        make.centerX.mas_equalTo(topView);
    }];
    
    
    UILabel *daiLabel=[UILabel new];
    [_scrollView addSubview:daiLabel];
    [daiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(imageView);
        make.width.mas_equalTo(_mainW-30);
        make.top.mas_equalTo(imageView.mas_bottom).mas_equalTo(20);
    }];
    
    daiLabel.textColor=_backgroundColor;
    daiLabel.font=[UIFont systemFontOfSize:18];
    daiLabel.textAlignment=NSTextAlignmentCenter;
    NSNumber *document_status=[_dic objectForKey:@"litigation_status"];
    
    
    
    if (document_status.integerValue==0) {
        imageView.image=[UIImage imageNamed:@"待回访"];
        daiLabel.text=@"平台将尽快回复您，请耐心等待...";
    }
    if (document_status.integerValue==1) {
        imageView.image=[UIImage imageNamed:@"待签约"];
        daiLabel.text=@"平台将尽快联系您签约，请保持电话通畅...";
    }
    if (document_status.integerValue==2||document_status.integerValue==3||document_status.integerValue==4||document_status.integerValue==5) {
        imageView.hidden=YES;
        daiLabel.hidden=YES;
        [self creaFangAnView:topView];
        _scrollView.contentSize = CGSizeMake(0,1000);
    }if (document_status.integerValue==3||document_status.integerValue==4||document_status.integerValue==5) {
        [self crewatLVShi:topView];
        
        _scrollView.contentSize = CGSizeMake(0,1000);
        
    }
    
    
    
    UIButton *btn1=[UIButton new];
    [self addSubview:btn1];
    [btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.width.mas_equalTo(_mainW);
        make.height.mas_equalTo(50);
        make.bottom.mas_equalTo(0);
    }];
    [btn1 setTitle:@"案件进度" forState:0];
    [btn1 setTitleColor:[UIColor whiteColor] forState:0];
    btn1.backgroundColor=_backgroundColor;
    [btn1 addTarget:self action:@selector(pushToJinDu:) forControlEvents:UIControlEventTouchUpInside];
    
    
}
-(void)creaFangAnView:(UIView *)topView{
    UIView *view=[UIView new];
    [_scrollView addSubview:view];
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(topView);
        make.top.mas_equalTo(topView.mas_bottom).mas_equalTo(10);
        make.height.mas_equalTo(180);
    }];
    view.backgroundColor=[UIColor whiteColor];
    UIView *xianView=[UIView new];
    [view addSubview:xianView];
    [xianView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(10);
        make.width.mas_equalTo(3);
        make.height.mas_equalTo(20);
    }];
    xianView.backgroundColor=_backgroundColor;
    
    UILabel *woDeLabel=[UILabel new];
    [view addSubview:woDeLabel];
    [woDeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(xianView);
        make.left.mas_equalTo(xianView.mas_right).mas_equalTo(10);
    }];
    woDeLabel.text=@"执行方案";
    woDeLabel.textColor=ColorWithRGB(49, 49, 49);
    woDeLabel.font=[UIFont systemFontOfSize:22];
    
    NSNumber *sl_check=[_dic objectForKey:@"sl_check"];
    if ([sl_check isKindOfClass:[NSNull class]]) {
        sl_check=@0;
    }
    
    if (sl_check.integerValue!=1 && sl_check.integerValue!=4) {
        UIImageView *lsImage=[UIImageView new];
        [view addSubview:lsImage];
        [lsImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(50);
            make.centerY.mas_equalTo(0);
            make.width.mas_equalTo(50);
            make.height.mas_equalTo(60);
        }];
        lsImage.image=[UIImage imageNamed:@"律师服务"];
        
        UILabel *dengDai=[UILabel new];
        [view addSubview:dengDai];
        [dengDai mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(lsImage.mas_right).mas_equalTo(20);
            make.centerY.mas_equalTo(0);
            make.right.mas_equalTo(-20);
        }];
        dengDai.text=@"专家正在为你出详细方案，请耐心等待...";
        dengDai.numberOfLines=0;
        dengDai.textColor=ColorWithRGB(219, 175, 0);
        dengDai.font=[UIFont systemFontOfSize:22];
    }else if (sl_check.integerValue==4) {
        UIView *xianZaiView=[UIView new];
        [view addSubview:xianZaiView];
        [xianZaiView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(10);
            make.width.mas_equalTo(100);
            make.centerY.mas_equalTo(10);
            make.height.mas_equalTo(100);
        }];
        xianZaiView.layer.borderColor=_LightGrey.CGColor;
        xianZaiView.layer.borderWidth=1;
        xianZaiView.userInteractionEnabled=YES;
        UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(xiazai)];
        [xianZaiView addGestureRecognizer:tapGesture];
        
        UIImageView *xiaZai=[UIImageView new];
        [xianZaiView addSubview:xiaZai];
        [xiaZai mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(0);
            make.top.mas_equalTo(15);
            make.width.height.mas_equalTo(30);
        }];
        xiaZai.image=[UIImage imageNamed:@"下载文件"];
        
        UIView *xianView3=[UIView new];
        [xianZaiView addSubview:xianView3];
        [xianView3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.mas_equalTo(0);
            make.bottom.mas_equalTo(-30);
            make.height.mas_equalTo(1);
        }];
        xianView3.backgroundColor=_LightGrey;
        
        UILabel *lable23=[UILabel new];
        [xianZaiView addSubview:lable23];
        [lable23 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(0);
            make.top.mas_equalTo(xianView3.mas_bottom).mas_equalTo(5);
        }];
        lable23.text=@"下载律师函";
        lable23.textColor=ColorWithRGB(149, 149, 149);
        lable23.font=[UIFont systemFontOfSize:15];
        
        UIImageView *imageView2=[UIImageView new];
        [view addSubview:imageView2];
        [imageView2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-15);
            make.centerY.mas_equalTo(0);
            make.height.mas_equalTo(40);
            make.width.mas_equalTo(65);
        }];
        imageView2.image=[UIImage imageNamed:@"已采纳"];
    }
    else{
        UIView *xianZaiView=[UIView new];
        [view addSubview:xianZaiView];
        [xianZaiView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(10);
            make.width.mas_equalTo(100);
            make.centerY.mas_equalTo(10);
            make.height.mas_equalTo(100);
        }];
        xianZaiView.layer.borderColor=_LightGrey.CGColor;
        xianZaiView.layer.borderWidth=1;
        xianZaiView.userInteractionEnabled=YES;
        UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(xiazai)];
        [xianZaiView addGestureRecognizer:tapGesture];
        
        UIImageView *xiaZai=[UIImageView new];
        [xianZaiView addSubview:xiaZai];
        [xiaZai mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(0);
            make.top.mas_equalTo(15);
            make.width.height.mas_equalTo(30);
        }];
        xiaZai.image=[UIImage imageNamed:@"下载文件"];
        
        UIView *xianView3=[UIView new];
        [xianZaiView addSubview:xianView3];
        [xianView3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.mas_equalTo(0);
            make.bottom.mas_equalTo(-30);
            make.height.mas_equalTo(1);
        }];
        xianView3.backgroundColor=_LightGrey;
        
        UILabel *lable23=[UILabel new];
        [xianZaiView addSubview:lable23];
        [lable23 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(0);
            make.top.mas_equalTo(xianView3.mas_bottom).mas_equalTo(5);
        }];
        lable23.text=@"下载律师函";
        lable23.textColor=ColorWithRGB(149, 149, 149);
        lable23.font=[UIFont systemFontOfSize:15];
        
        UIButton *btn=[UIButton new];
        [view addSubview:btn];
        [btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(xianZaiView.mas_right).mas_equalTo(20);
            make.bottom.mas_equalTo(xianZaiView);
            make.height.mas_equalTo(30);
            make.width.mas_equalTo(80);
        }];
        btn.backgroundColor=ColorWithRGB(183, 157, 108);
        btn.layer.cornerRadius=3;
        [btn setTitleColor:[UIColor whiteColor] forState:0];
        [btn setTitle:@"采纳" forState:0];
        [btn addTarget:self action:@selector(creawtCaiNa:) forControlEvents:UIControlEventTouchUpInside];
        UIButton *btn2=[UIButton new];
        [view addSubview:btn2];
        [btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(btn.mas_right).mas_equalTo(20);
            make.bottom.mas_equalTo(xianZaiView);
            make.height.mas_equalTo(30);
            make.width.mas_equalTo(80);
        }];
        btn2.backgroundColor=ColorWithRGB(93, 148, 172);
        btn2.layer.cornerRadius=3;
        [btn2 setTitleColor:[UIColor whiteColor] forState:0];
        [btn2 setTitle:@"拒绝" forState:0];
        [btn2 addTarget:self action:@selector(creawtCaiNa2:) forControlEvents:UIControlEventTouchUpInside];
    }
    
}

-(void)crewatLVShi:(UIView *)topView{
    
     UIView *LSView=[UIView new];
    NSDictionary *lawyer_info=[_dic objectForKey:@"lawyer_info"];
    [_scrollView addSubview:LSView];
    [LSView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(topView);
        make.height.mas_equalTo(120);
        make.top.mas_equalTo(topView.mas_bottom).mas_equalTo(200);
    }];
    LSView.backgroundColor=[UIColor whiteColor];
    LSView.layer.cornerRadius=3;
    
    UIView *xianView=[UIView new];
    [LSView addSubview:xianView];
    [xianView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(10);
        make.width.mas_equalTo(3);
        make.height.mas_equalTo(20);
    }];
    xianView.backgroundColor=_backgroundColor;
    
    UILabel *woDeLabel=[UILabel new];
    [LSView addSubview:woDeLabel];
    [woDeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(xianView);
        make.left.mas_equalTo(xianView.mas_right).mas_equalTo(10);
    }];
    woDeLabel.text=@"我的律师";
    woDeLabel.textColor=ColorWithRGB(49, 49, 49);
    woDeLabel.font=[UIFont systemFontOfSize:22];
    
    
    UIImageView *userImage=[UIImageView new];
    [LSView addSubview:userImage];
    [userImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(woDeLabel.mas_bottom).mas_equalTo(15);
        make.width.height.mas_equalTo(50);
    }];
    userImage.layer.masksToBounds=YES;
    userImage.layer.cornerRadius=25;
    NSString *waiter_icon=[lawyer_info objectForKey:@"waiter_icon"];
    waiter_icon=[NSString stringWithFormat:@"%@%@",_addressUrl,waiter_icon];
    [userImage sd_setImageWithURL:[NSURL URLWithString:waiter_icon]];
    
    UILabel *nameLabel=[UILabel new];
    [LSView addSubview:nameLabel];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(userImage.mas_top);
        make.left.mas_equalTo(userImage.mas_right).mas_equalTo(15);
    }];
    nameLabel.textColor=ColorWithRGB(49, 49, 49);
    nameLabel.text=[lawyer_info objectForKey:@"waiter_name"];
    nameLabel.font=[UIFont systemFontOfSize:17];
    float width=0;
    UILabel *label=[UILabel new];
    [LSView addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(nameLabel);
        make.left.mas_equalTo(nameLabel.mas_right).mas_equalTo(15);
        make.width.mas_equalTo(80);
    }];
    label.text=@"执业十年";
    label.textAlignment=NSTextAlignmentCenter;
    label.font=[UIFont systemFontOfSize:14];
    label.textColor=[UIColor whiteColor];
    label.backgroundColor=ColorWithRGB(31, 171, 223);
    label.layer.cornerRadius=2;
    
    NSString *wl_field_names=[lawyer_info objectForKey:@"wl_field_names"];
    
    
    
    NSArray *biaoQian=[wl_field_names componentsSeparatedByString:@","];
    int abc=biaoQian.count;
    if (abc>2) {
        abc=2;
    }
    for (int i=0; i<abc; i++) {
        NSString *biaoStr=biaoQian[i];
        CGSize size=[ZQTools getNSStringWeight:biaoStr andViewWight:16 andFont:16 ];
        
        UILabel *label=[UILabel new];
        [LSView addSubview:label];
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(userImage.mas_right).mas_equalTo(15+width);
            make.height.mas_equalTo(20);
            make.width.mas_equalTo(size.width+16);
            make.bottom.mas_equalTo(userImage);
        }];
        label.text=biaoQian[i];
        label.font=[UIFont systemFontOfSize:16];
        label.textColor=ColorWithRGB(149, 149, 149);
        label.layer.cornerRadius=4;
        label.layer.borderColor=ColorWithRGB(149,149, 149).CGColor;
        label.layer.borderWidth=1;
        label.textAlignment=NSTextAlignmentCenter;
        width=width+size.width+30;
    }
}



-(void)creatView1{
    UIView *topView=[UIView new];
    [_scrollView addSubview:topView];
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(5);
        make.width.mas_equalTo(_mainW-10);
        make.height.mas_equalTo(101);
        make.top.mas_equalTo(195);
    }];
    topView.backgroundColor=[UIColor whiteColor];
    topView.layer.cornerRadius=3;
    
    UIView *nameView=[UIView new];
    [topView addSubview:nameView];
    [nameView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(0);
        make.height.mas_equalTo(50);
    }];
    UIImageView *nameImage=[UIImageView new];
    [nameView addSubview:nameImage];
    [nameImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(10);
        make.width.mas_equalTo(15);
        make.height.mas_equalTo(20);
    }];
    nameImage.image=[UIImage imageNamed:@"我的"];
    
    UILabel *nameLabel=[UILabel new];
    [nameView addSubview:nameLabel];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(nameImage.mas_right).mas_equalTo(10);
        make.centerY.mas_equalTo(0);
    }];
    nameLabel.font=[UIFont systemFontOfSize:17];
    nameLabel.text=@"你的称呼";
    nameLabel.textColor=ColorWithRGB(49, 49, 49);
    
    _nameText=[UITextField new];
    [nameView addSubview:_nameText];
    [_nameText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(150);
        make.height.mas_equalTo(40);
    }];
    _nameText.placeholder=@"请输入你的真实姓名";
    _nameText.font=[UIFont systemFontOfSize:15];
    _nameText.textColor=ColorWithRGB(49, 49, 49);
    _nameText.delegate=self;
    _nameText.returnKeyType=UIReturnKeyDone;
    _nameText.textAlignment=NSTextAlignmentRight;
    
    UIView *xianView=[UIView new];
    [topView addSubview:xianView];
    [xianView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.height.mas_equalTo(1);
        make.top.mas_equalTo(nameView.mas_bottom);
    }];
    xianView.backgroundColor=_LightGrey;
    
    UIView *addView=[UIView new];
    [topView addSubview:addView];
    [addView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(0);
        make.height.mas_equalTo(50);
    }];
    UIImageView *addImage=[UIImageView new];
    [addView addSubview:addImage];
    [addImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(10);
        make.width.mas_equalTo(15);
        make.height.mas_equalTo(20);
    }];
    addImage.image=[UIImage imageNamed:@"location"];
    
    UIImageView *imgaeView=[UIImageView new];
    [addView addSubview:imgaeView];
    [imgaeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(0);
        make.width.mas_equalTo(12);
        make.height.mas_equalTo(20);
    }];
    imgaeView.image=[UIImage imageNamed:@"iconfont-fanhui-拷贝-3"];
    
    UILabel *addLabel=[UILabel new];
    [addView addSubview:addLabel];
    [addLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(nameImage.mas_right).mas_equalTo(10);
        make.centerY.mas_equalTo(0);
    }];
    addLabel.font=[UIFont systemFontOfSize:17];
    addLabel.text=@"案件所在地";
    addLabel.textColor=ColorWithRGB(49, 49, 49);
    
    _addLabel=[UILabel new];
    [addView addSubview:_addLabel];
    [_addLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(imgaeView.mas_left).mas_equalTo(-5);
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(150);
    }];
    _addLabel.textAlignment=NSTextAlignmentRight;
    _addLabel.text=@"";
    _addLabel.font=[UIFont systemFontOfSize:15];
    _addLabel.textColor=ColorWithRGB(49, 49, 49);
    
    addView.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(SelectAdd:)];
    [addView addGestureRecognizer:tapGesture];
    
    
    UIView *caseView=[UIView new];
    [_scrollView addSubview:caseView];
    [caseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(topView);
        make.top.mas_equalTo(addView.mas_bottom).mas_equalTo(12);
        make.height.mas_equalTo(55);
    }];
    caseView.backgroundColor=[UIColor whiteColor];
    caseView.layer.cornerRadius=3;
    
    caseView.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapGesture2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(SelectCase:)];
    [caseView addGestureRecognizer:tapGesture2];

    UIImageView *caseImage=[UIImageView new];
    [caseView addSubview:caseImage];
    [caseImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.centerX.mas_equalTo(-40);
        make.width.height.mas_equalTo(25);
    }];
    caseImage.image=[UIImage imageNamed:@"选择案件类型"];
    
    _caseLabel=[UILabel new];
    [caseView addSubview:_caseLabel];
    [_caseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(caseImage.mas_right).mas_equalTo(10);
        make.centerY.mas_equalTo(0);
    }];
    _caseLabel.text=@"选择案件类型";
    _caseLabel.font=[UIFont systemFontOfSize:18];
    _caseLabel.textColor=ColorWithRGB(49, 49, 49);
    
    _bottomView=[UIView new];
    [_scrollView addSubview:_bottomView];
    [_bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(topView);
        make.height.mas_equalTo(250);
        make.top.mas_equalTo(caseView.mas_bottom).mas_equalTo(20);
    }];
    
    
    _xieYiImage=[UIImageView new];
    [_bottomView addSubview:_xieYiImage];
    [_xieYiImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.width.height.mas_equalTo(25);
        make.top.mas_equalTo(20);
    }];
    if (_xieYi) {
        _xieYiImage.image=[UIImage imageNamed:@"是"];
    }else{
        _xieYiImage.image=[UIImage imageNamed:@"否"];
    }
    _xieYiImage.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapGesture12 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(creatXieYe:)];
    [_xieYiImage addGestureRecognizer:tapGesture12];

    
    UILabel *xieYiLabel=[UILabel new];
    [_bottomView addSubview:xieYiLabel];
    [xieYiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_xieYiImage.mas_right).mas_equalTo(20);
        make.centerY.mas_equalTo(_xieYiImage);
    }];
    NSMutableAttributedString *AttributedStr= [[NSMutableAttributedString alloc]initWithString:@"同意《独角兽平台声明》"];
    
    [AttributedStr addAttribute:NSForegroundColorAttributeName value:ColorWithRGB(149, 149, 149) range:NSMakeRange(0, 2)];
    [AttributedStr addAttribute:NSForegroundColorAttributeName value:ColorWithRGB(186, 151, 89) range:NSMakeRange(2, 9)];
    xieYiLabel.attributedText=AttributedStr;
    xieYiLabel.font=[UIFont systemFontOfSize:16];
    xieYiLabel.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapGesture13 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushToXieyi:)];
    [xieYiLabel addGestureRecognizer:tapGesture13];
    
    _btn=[UIButton new];
    [_bottomView addSubview:_btn];
    [_btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.right.mas_equalTo (-20);
        make.height.mas_equalTo(50);
        make.bottom.mas_equalTo(-20);
    }];
    [_btn setTitle:@"提交" forState:0];
    [_btn setTitleColor:[UIColor whiteColor] forState:0];
    _btn.layer.cornerRadius=10;
    _btn.backgroundColor=_backgroundColor;
    [_btn addTarget:self action:@selector(tijiao:) forControlEvents:UIControlEventTouchUpInside];
    
}
-(void)SelectAdd:(UITapGestureRecognizer *)tap{
    selectRegionView *addView=[selectRegionView new];
    [self addSubview:addView];
    [addView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.mas_equalTo(0);
    }];
    addView.customSelectedBlock = ^ (NSDictionary *dic)
    {
        NSString *mergename=[dic objectForKey:@"mergename"];
        NSArray *nameArr=[mergename componentsSeparatedByString:@","];
        NSString *addStr=@"";
        for (int i=0;i< nameArr.count; i++) {
            addStr=[NSString stringWithFormat:@"%@%@",addStr,nameArr[i]];
        }
        _addDic=dic;
        [self getLSList];
        _addLabel.text=addStr;
        
    };
    addView.index2=2;
    [addView creatView];
    
}
-(void)SelectCase:(UITapGestureRecognizer *)tap{
    SelectCaseView *addView=[SelectCaseView new];
    [self addSubview:addView];
    [addView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.mas_equalTo(0);
    }];
    addView.customSelectedBlock = ^ (NSDictionary *dic)
    {
        _caseDic=dic;
        [self getLSList];
        [self getCaseViewData];
    };
    addView.index2=3;
    [addView creatView];
}

-(void)getCaseViewData{
    NSNumber *ids=[_caseDic objectForKey:@"ct_id"];
    _caseLabel.text=[_caseDic objectForKey:@"ct_name"];
    NSDictionary *dic=[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%@",ids],@"ct_id", nil];
    [ZQTools AFNPostDataUrl:@"user/litigation/get_problem" Dict:dic andTableView:nil andViewController:self.viewController andSuccessBlock:^(id responseObject) {
        
        _tableArr=responseObject;
        [self creatCaseView:responseObject];
        
    } anderrorBlock:nil];
    
}

-(void)creatCaseView:(NSArray *)tableArr{
    
 
    [_view removeFromSuperview];
    _view=[UIView new];
    [_scrollView addSubview:_view];
    _view.backgroundColor=[UIColor whiteColor];
    _btnArr=[NSMutableArray arrayWithCapacity:0];
    _textArr=[NSMutableArray arrayWithCapacity:0];
    _numArr=[NSMutableArray arrayWithCapacity:0];
    
    

    float height=0;
    for (int i=1; i<=tableArr.count; i++) {
        NSDictionary *dic=tableArr[i-1];
        NSNumber *problem_answer_type=[dic objectForKey:@"problem_answer_type"];
        if (problem_answer_type.intValue==1) {
            NSString *problem_title=[dic objectForKey:@"problem_title"];
            CGSize size=[ZQTools getNSStringSize:problem_title andViewWight:_mainW-35 andFont:15];
            UILabel *titleLabel=[UILabel new];
            [_view addSubview:titleLabel];
            [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.mas_equalTo(20+height);
                make.left.mas_equalTo(10);
                make.right.mas_equalTo(-10);
                make.height.mas_equalTo(size.height);
            }];
            titleLabel.text=[NSString stringWithFormat:@"%d.%@",i,problem_title];
            titleLabel.textColor=ColorWithRGB(49,49 , 49);
            titleLabel.font=[UIFont systemFontOfSize:15];

            height=height+size.height+30;

            NSArray *problem_answer=[dic objectForKey:@"problem_answer"];
            for (int j=0 ; j<problem_answer.count; j++) {
                UIImageView *iamgeView=[UIImageView new];
                [_view addSubview:iamgeView];
                [iamgeView mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.mas_equalTo(25);
                    make.width.height.mas_equalTo(25);
                    make.top.mas_equalTo(titleLabel.mas_bottom).mas_equalTo(10+40*j);
                }];
                height=height+40;
                
                if (j==0) {
                    iamgeView.image=[UIImage imageNamed:@"是"];
                    [_numArr addObject:[NSString stringWithFormat:@"%d",i*10000+j]];
                }else{
                    iamgeView.image=[UIImage imageNamed:@"否"];
                }
                iamgeView.tag=i*10000+j;
                iamgeView.userInteractionEnabled=YES;
                UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectWenTi:)];
                [iamgeView addGestureRecognizer:tapGesture];
                
                [_btnArr addObject:iamgeView];
                
                UILabel *answerLabel=[UILabel new];
                [_view addSubview:answerLabel];
                [answerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.mas_equalTo(iamgeView.mas_right).mas_equalTo(10);
                    make.right.mas_equalTo(-10);
                    make.centerY.mas_equalTo(iamgeView);
                }];
                
                answerLabel.text=[NSString stringWithFormat:@"%@",problem_answer[j]];
                answerLabel.textColor=ColorWithRGB(49, 49, 49);
                answerLabel.font=[UIFont systemFontOfSize:16];
                answerLabel.userInteractionEnabled=YES;
                answerLabel.tag=i*10000+j;
                UITapGestureRecognizer *tapGesture2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectWenTi:)];
                [answerLabel addGestureRecognizer:tapGesture2];
            }
        }
        else{
            NSString *problem_title=[dic objectForKey:@"problem_title"];
            CGSize size=[ZQTools getNSStringSize:problem_title andViewWight:_mainW-35 andFont:15];
            UILabel *titleLabel=[UILabel new];
            [_view addSubview:titleLabel];
            [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.mas_equalTo(20+height);
                make.left.mas_equalTo(10);
                make.right.mas_equalTo(-10);
                make.height.mas_equalTo(size.height);
            }];
            titleLabel.text=[NSString stringWithFormat:@"%d.%@",i,problem_title];
            titleLabel.textColor=ColorWithRGB(49,49 , 49);
            titleLabel.font=[UIFont systemFontOfSize:15];

            height=height+size.height+30;


            UITextField *textFiled=[UITextField new];
            [_view addSubview:textFiled];
            [textFiled mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(20);
                make.right.mas_equalTo(-20);
                make.top.mas_equalTo(titleLabel.mas_bottom).mas_equalTo(15);
                make.height.mas_equalTo(40);
            }];
            textFiled.layer.cornerRadius=4;
            textFiled.layer.borderColor=_LightGrey.CGColor;
            textFiled.layer.borderWidth=1;
            textFiled.placeholder=@"请输入内容";
            textFiled.delegate=self;
            textFiled.leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 8, 0)];
            textFiled.leftViewMode = UITextFieldViewModeAlways;
            textFiled.tag=i;
            [_textArr addObject:textFiled];
            height=height+50;

        }

    }
    [_view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(5);
        make.width.mas_equalTo(_mainW-10);
        make.height.mas_equalTo(height+30);
        make.top.mas_equalTo(380);
    }];

    UIImageView *lianJieImage=[UIImageView new];
    [_scrollView addSubview:lianJieImage];
    [lianJieImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(40);
        make.top.mas_equalTo(360);
        make.width.mas_equalTo(15);
        make.height.mas_equalTo(40);
    }];
    lianJieImage.image=[UIImage imageNamed:@"纽带"];

    UIImageView *lianJieImage2=[UIImageView new];
    [_scrollView addSubview:lianJieImage2];
    [lianJieImage2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(_mainW-55);
        make.top.mas_equalTo(350);
        make.width.mas_equalTo(15);
        make.height.mas_equalTo(40);
    }];
    lianJieImage2.image=[UIImage imageNamed:@"纽带"];

    _scrollView.contentSize = CGSizeMake(0,700+height+30);
    
    
    [_bottomView removeFromSuperview];
    _bottomView=[UIView new];
    [_scrollView addSubview:_bottomView];
    [_bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(_view);
        make.height.mas_equalTo(250);
        make.top.mas_equalTo(_view.mas_bottom).mas_equalTo(20);
    }];


    _xieYiImage=[UIImageView new];
    [_bottomView addSubview:_xieYiImage];
    [_xieYiImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.width.height.mas_equalTo(25);
        make.top.mas_equalTo(20);
    }];
    if (_xieYi) {
        _xieYiImage.image=[UIImage imageNamed:@"是"];
    }else{
        _xieYiImage.image=[UIImage imageNamed:@"否"];
    }
    _xieYiImage.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapGesture12 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(creatXieYe:)];
    [_xieYiImage addGestureRecognizer:tapGesture12];

    UILabel *xieYiLabel=[UILabel new];
    [_bottomView addSubview:xieYiLabel];
    [xieYiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_xieYiImage.mas_right).mas_equalTo(20);
        make.centerY.mas_equalTo(_xieYiImage);
    }];
    NSMutableAttributedString *AttributedStr= [[NSMutableAttributedString alloc]initWithString:@"同意《独角兽平台声明》"];

    [AttributedStr addAttribute:NSForegroundColorAttributeName value:ColorWithRGB(149, 149, 149) range:NSMakeRange(0, 2)];
    [AttributedStr addAttribute:NSForegroundColorAttributeName value:ColorWithRGB(186, 151, 89) range:NSMakeRange(2, 9)];
    xieYiLabel.attributedText=AttributedStr;
    xieYiLabel.font=[UIFont systemFontOfSize:16];
    UITapGestureRecognizer *tapGesture13 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushToXieyi:)];
    [xieYiLabel addGestureRecognizer:tapGesture13];

    _btn=[UIButton new];
    [_bottomView addSubview:_btn];
    [_btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.right.mas_equalTo (-20);
        make.height.mas_equalTo(50);
        make.bottom.mas_equalTo(-20);
    }];
    if (_lawyerArr!=nil&&_lawyerArr.count!=0) {
        [_btn setTitle:@"下一步" forState:0];
    }
    else{
        [_btn setTitle:@"提交" forState:0];
    }
    
    [_btn setTitleColor:[UIColor whiteColor] forState:0];
    _btn.layer.cornerRadius=10;
    _btn.backgroundColor=_backgroundColor;
    [_btn addTarget:self action:@selector(tijiao:) forControlEvents:UIControlEventTouchUpInside];

}


-(void)selectWenTi:(UITapGestureRecognizer *)tap{
    
    NSInteger typeI=tap.view.tag/10000;
    NSInteger typeW=tap.view.tag%10000;
    for (int i=0; i<_btnArr.count; i++) {
        UIImageView *iamgeView=_btnArr[i];
        NSInteger typeI2=iamgeView.tag/10000;
        NSInteger typeW2=iamgeView.tag%10000;
        if (typeI==typeI2) {
            if (typeW==typeW2) {
                iamgeView.image=[UIImage imageNamed:@"是"];
            }
            else{
                iamgeView.image=[UIImage imageNamed:@"否"];
            }
        }
    }
    
    for (int i=0; i<_numArr.count; i++) {
        NSString *selectNum=_numArr[i];
        NSInteger typeI2=selectNum.integerValue/10000;
        if (typeI==typeI2) {
            [_numArr replaceObjectAtIndex:i withObject:[NSString stringWithFormat:@"%ld",tap.view.tag]];
            break;
        }
    }
    
    
}
-(IBAction)tijiao:(UIButton *)sender{
    if (!_xieYi) {
        [ZQTools svpInfo:@"你还没有同意平台声明"];
        return;
    }
    NSString *litigation_party_name=_nameText.text;
    if ([ZQTools charIsNil:litigation_party_name]) {
        [ZQTools svpInfo:@"你的真实姓名不能为空"];
        return;
    }
    if (_addDic==nil) {
        [ZQTools svpInfo:@"你还没有选择案件所在地"];
        return;
    }
    if (_caseDic==nil) {
        [ZQTools svpInfo:@"你还没有选择案件类型"];
        return;
    }
    
    NSMutableArray *answer_problem=[NSMutableArray arrayWithCapacity:0];
    for (int i=1; i<=_tableArr.count; i++) {
        NSDictionary *dic=_tableArr[i-1];
        NSNumber *problem_answer_type=[dic objectForKey:@"problem_answer_type"];
        NSMutableDictionary *answer_problemDic=[NSMutableDictionary dictionaryWithCapacity:0];
        if (problem_answer_type.intValue==1) {
            for (int j=0; j<_numArr.count; j++) {
                NSString *selectNum=_numArr[j];
                NSInteger typeI2=selectNum.integerValue/10000;
                NSInteger typeW2=selectNum.integerValue%10000;
                if (typeI2==i) {
                    [answer_problemDic setObject:[dic objectForKey:@"problem_title"] forKey:@"title"];
                    NSArray *problem_answer=[dic objectForKey:@"problem_answer"];
                    [answer_problemDic setObject:problem_answer[typeW2] forKey:@"content"];
                }
            }
            
        }
        else{
            for (int j=0; j<_textArr.count; j++) {
                UITextField *text=_textArr[j];
                if ([ZQTools charIsNil:text.text]) {
                    [ZQTools svpInfo:[NSString stringWithFormat:@"%@的答案不能为空",[dic objectForKey:@"problem_title"]]];
                    return;
                }
                if (text.tag==i) {
                    [answer_problemDic setObject:[dic objectForKey:@"problem_title"] forKey:@"title"];
                    [answer_problemDic setObject:text.text forKey:@"content"];
                }
            }
        }
        [answer_problem addObject:answer_problemDic];
    }
    
    NSDictionary *userDic = [NSKeyedUnarchiver unarchiveObjectWithFile:_userModelFile];
    NSString *token=[userDic objectForKey:@"token"];
    NSNumber *waiter_id1=[userDic objectForKey:@"user_id"];
    NSString *user_id=[NSString stringWithFormat:@"%@",waiter_id1];
    
    NSNumber *dt_id1=[_caseDic objectForKey:@"ct_id"];
    NSString *ct_id=[NSString stringWithFormat:@"%@",dt_id1];
    
    NSNumber *city_id1=[_addDic objectForKey:@"id"];
    NSString *city_id=[NSString stringWithFormat:@"%@",city_id1];

    
    NSDictionary *dic=[NSDictionary dictionaryWithObjectsAndKeys:litigation_party_name,@"litigation_party_name",city_id,@"city_id",ct_id,@"ct_id",answer_problem,@"answer_problem", nil];
    
   
    
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:nil];
 
    NSString *content=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    
     NSDictionary *dict=[NSDictionary dictionaryWithObjectsAndKeys:user_id,@"user_id",@"0",@"user_role",content,@"content",token,@"token", nil];
    NSString *btnStr=sender.titleLabel.text;
    if ([btnStr isEqualToString:@"提交"]) {
        [ZQTools AFNPostDataUrl:@"user/litigation/send_litigation" Dict:dict andTableView:nil andViewController:self.viewController andSuccessBlock:^(id responseObject) {
            OKViewController *okView=[[OKViewController alloc] init];
            okView.dic=[NSDictionary dictionaryWithObjectsAndKeys:responseObject,@"litigation_id",@"发布案件",@"neixin", nil];
            [ZQTools pushNextViewController:self.viewController andRootController:okView];
        } anderrorBlock:nil];
    }
    else{
        XLSViewController *XLS=[[XLSViewController alloc] init];
        XLS.dic=dict;
        XLS.typeArr=_lawyerArr;
        [ZQTools pushNextViewController:self.viewController andRootController:XLS];
    }
    
    
    
}

-(IBAction)pushToJinDu:(id)sender{
    CaseProgressViewController *caseView=[[CaseProgressViewController alloc] init];
    caseView.litigation_id=[_dic objectForKey:@"litigation_id"];
    [ZQTools pushNextViewController:self.viewController andRootController:caseView];
    
}
    

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString*)string{
    if ([[[UITextInputMode currentInputMode]primaryLanguage] isEqualToString:@"emoji"]) {
        return NO;
    }
    return YES;
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}
-(void)xiazai {
    
    
    
    NSString *str=[_dic objectForKey:@"sl_file"];
    NSString *cuo=[ZQTools NSDateToTimeCuo:[NSDate new]];
    
    NSString * time=[ZQTools changeTimeCuo:@"yyyy-MM-dd":cuo];
    NSString * time2=[ZQTools changeTimeCuo:@"yyyy-MM-dd-HH:mm:ss":cuo];

    
    NSMutableDictionary  *dic=[NSMutableDictionary dictionaryWithCapacity:0];
    
    // 要下载文件的url
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",_addressUrl,str]];
    
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    NSURLSessionDownloadTask *task = [manager downloadTaskWithRequest:request progress:^(NSProgress * _Nonnull downloadProgress) {
        
        double daxiao=downloadProgress.totalUnitCount/1024;
        [dic setObject:[NSString stringWithFormat:@"%.2fKB",daxiao] forKey:@"size"];
        
    } destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) {
        
        NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
        NSLog(@"file = %@",targetPath);
        [dic setObject:[NSString stringWithFormat:@"%@_%@",time2,[response suggestedFilename]] forKey:@"filePath"];
        return [documentsDirectoryURL URLByAppendingPathComponent:[NSString stringWithFormat:@"%@_%@",time2,[response suggestedFilename]]];
        
        
        
    } completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) {
        
        [MBProgressHUD hideHUDForView:self animated:YES];
        [dic setObject:@"执行方案" forKey:@"title"]; 
        [dic setObject:time forKey:@"time"];
        
        [ZQTools svpInfo:@"下载成功，请在我的下载中查看"];
        NSArray *xiaArr = [NSKeyedUnarchiver unarchiveObjectWithFile:_xiaZai];
        
        NSMutableArray *typeArr=[NSMutableArray arrayWithArray:xiaArr];
        [typeArr addObject:dic];
        [NSKeyedArchiver archiveRootObject:typeArr toFile:_xiaZai];
        
        
    }];
    [task resume];//开始下载 要不然不会进行下载的
    
}
-(IBAction)creawtCaiNa:(id)sender{
    NSDictionary *userDic = [NSKeyedUnarchiver unarchiveObjectWithFile:_userModelFile];
    NSString *token=[userDic objectForKey:@"token"];
    NSNumber *waiter_id1=[userDic objectForKey:@"user_id"];
    NSString *user_id=[NSString stringWithFormat:@"%@",waiter_id1];
    NSNumber *sl_id1=[_dic objectForKey:@"sl_id"];
    NSString *sl_id=[NSString stringWithFormat:@"%@",sl_id1];
    NSNumber *litigation_id1=[_dic objectForKey:@"litigation_id"];
    NSString *litigation_id=[NSString stringWithFormat:@"%@",litigation_id1];
    
      NSDictionary *dic=[NSDictionary dictionaryWithObjectsAndKeys:sl_id,@"sl_id",litigation_id,@"litigation_id",token,@"token",user_id,@"user_id",@"0",@"user_role",@"1",@"action", nil];
    [ZQTools AFNPostDataUrl:@"user/litigation/accept_litigation" Dict:dic andTableView:nil andViewController:self.viewController andSuccessBlock:^(id responseObject) {
        _customSelectedBlock();
    } anderrorBlock:nil];

}
-(IBAction)creawtCaiNa2:(id)sender{
    NSDictionary *userDic = [NSKeyedUnarchiver unarchiveObjectWithFile:_userModelFile];
    NSString *token=[userDic objectForKey:@"token"];
    NSNumber *waiter_id1=[userDic objectForKey:@"user_id"];
    NSString *user_id=[NSString stringWithFormat:@"%@",waiter_id1];
    NSNumber *sl_id1=[_dic objectForKey:@"sl_id"];
    NSString *sl_id=[NSString stringWithFormat:@"%@",sl_id1];
    NSNumber *litigation_id1=[_dic objectForKey:@"litigation_id"];
    NSString *litigation_id=[NSString stringWithFormat:@"%@",litigation_id1];
    
    NSDictionary *dic=[NSDictionary dictionaryWithObjectsAndKeys:sl_id,@"sl_id",litigation_id,@"litigation_id",token,@"token",user_id,@"user_id",@"0",@"user_role",@"2",@"action", nil];
    [ZQTools AFNPostDataUrl:@"user/litigation/accept_litigation" Dict:dic andTableView:nil andViewController:self.viewController andSuccessBlock:^(id responseObject) {
        _customSelectedBlock();
    } anderrorBlock:nil];
    
}

-(void)getLSList{
 
    NSNumber *ids1=[_addDic objectForKey:@"id"];
    NSNumber *ids2=[_caseDic objectForKey:@"ct_id"];
    ids1=@2324;
    ids2=@9;
    NSDictionary *userDic = [NSKeyedUnarchiver unarchiveObjectWithFile:_userModelFile];

    NSNumber *waiter_id1=[userDic objectForKey:@"user_id"];
    NSString *user_id=[NSString stringWithFormat:@"%@",waiter_id1];
    NSDictionary *dic=[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%@",ids1],@"city_id",[NSString stringWithFormat:@"%@",ids2],@"ct_id",user_id,@"user_id", nil];
    
    [ZQTools AFNPostDataUrl:@"user/litigation/lawyer" Dict:dic andTableView:nil andViewController:self.viewController andSuccessBlock:^(id responseObject) {
        NSArray *typeArr=responseObject;
        if (typeArr.count!=0) {
             [_btn setTitle:@"下一步" forState:0];
        }else{
             [_btn setTitle:@"提交" forState:0];
        }
        _lawyerArr=responseObject;
    } anderrorBlock:nil];
}
-(void)creatXieYe:(UITapGestureRecognizer *)tap{
    if (_xieYi) {
        _xieYi=NO;
        _xieYiImage.image=[UIImage imageNamed:@"否"];
    }else{
        _xieYi=YES;
        _xieYiImage.image=[UIImage imageNamed:@"是"];
    }
}
-(void)XQMS{
    NSArray *answer=[_dic objectForKey:@"answer"];
    XQMSView *xqView=[XQMSView new];
    [self addSubview:xqView];
    [xqView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.mas_equalTo(0);
    }];
    xqView.typeArr=answer;
    [xqView creatView];
}

-(void)pushToXieyi:(UITapGestureRecognizer *)tap{
    WEBViewController *webView=[[WEBViewController alloc] init];
    webView.title=@"用户协议";
    webView.url=@"http://www.djiaoshou.com/index/index/user_register_agreement.html";
    [ZQTools pushNextViewController:self.viewController andRootController:webView];
}

@end
